﻿@model IEnumerable<ForumCategoryDto>
@{
	Layout = "~/Views/Shared/_ForumsLayout.cshtml";
}
@section TopRssLinks {
	<ul class="small-menu rss-menu">
	<li><a href="@Url.Action("Rss")">@Resources.EnetaMvc.RssAllForums</a></li>
	<li><a href="#">@Resources.EnetaMvc.RssAllReplies</a></li>
    @if (User.IsInRole("Administrator"))
    { 
        <li><a href="@Url.Action("CreateCategory")">@Resources.EnetaMvc.AddForumCategory</a></li>
    }
	</ul>
}
@section BottomRssLinks {
	<ul class="small-menu rss-menu">
	<li><a href="@Url.Action("Rss")">@Resources.EnetaMvc.RssAllForums</a></li>
	<li><a href="#">@Resources.EnetaMvc.RssAllReplies</a></li>
    </ul>
}
<p class="ms-navheader"> <a href='@Url.Content("~/forums/")'>@Resources.EnetaMvc.MainPage</a></p>

<table width=100% cellspacing=0 cellpadding=3>
<tr>
	<td width="1%" class="ms-ToolPaneTitle">&nbsp;</td>
	<td align="left" class="ms-ToolPaneTitle">@Resources.EnetaMvc.Forum</td>
	<td align="center" width="7%" class="ms-ToolPaneTitle">@Resources.EnetaMvc.TopicsNo</td>
	<td align="center" width="7%" class="ms-ToolPaneTitle">@Resources.EnetaMvc.PostsNo</td>
	<td align="center" width="22%" class="ms-ToolPaneTitle">@Resources.EnetaMvc.LastPost</td><!-- Lembit 29.06.2009: 25% => 22% -->
</tr>
@foreach(var category in Model)
{
<tr>
	<td class="ms-TPHeader" colspan="5">
        <a href="@Url.Content("~/forums/category/" + category.Id)"><strong>@category.Name</strong></a>
        @if (User.IsInRole("Administrator"))
        { 
            <div style="float:right;">
                <a href="@Url.Action("EditCategory", new { id = category.Id })" style="font-size:10pt">@Resources.EnetaMvc.Edit</a> | 
                <a href="@Url.Action("DeleteCategory", new { id = category.Id })" style="font-size:10pt">@Resources.EnetaMvc.Delete</a> 
            </div>
        }
    </td>
</tr>
	foreach(var forum in category.Forums)
	{
	<tr class="ms-alternating">
		<td valign="top"><img src="@Url.Content("~/images/icon-folder.gif")"></td>
		<td valign="top"><a href="@Url.Content("~/forums/forum/" + forum.Id)">@forum.Name</a><br>
			@forum.Description
			<!-- Lembit 29.06.2009: moderaator -->
			<div class="mode"><span>@Resources.EnetaMvc.Moderator</span> 
				@foreach(var moderator in forum.Moderators)
				{
					<a title="@moderator.UserName" href="@Url.Content("~/profiles/details/" + moderator.Id)"> 
						<img width="16" height="16" src="@Html.GetProfileUrl(moderator.Id, 16)" alt="@moderator.UserName"/>
						<span>@moderator.UserName</span>
					</a>
				}
			</div>
			<!-- end moderaator --></td>
		<td align="center" valign="top">@forum.TopicsCount</td>
		<td align="center" valign="top">@forum.PostsCount</td>
		<td valign="top" align="center"> 
			@if(forum.LastPost != null)
			{
				<a href="@Url.Content("~/forums/topic/" + forum.LastPost.TopLevelPostId)">@forum.LastPost.GetShortTitle()</a><br />
				@forum.LastPost.Created.ToShortDateString()<br/>
				<a href="@Url.Content("~/profiles/details/" + forum.LastPost.CreatedById)">@forum.LastPost.CreatedByUserName</a> 
			}
		</td>
	</tr>
	}
}
</table>